﻿//自动义双击方法
function CustomDbClick() {

}
//格式化到达时间
var fnArrive = function (elCell, oRecord, oColumn, sData) {
    if (sData == "0001-01-01 " || sData == "1900-01-01 " || sData == null) {
        elCell.innerHTML = "";
    } else {
        elCell.innerHTML = sData;
    }
}
//格式化毕业时间
var fnOver = function (elCell, oRecord, oColumn, sData) {
    if (sData == "0001-01-01 " || sData == "1900-01-01 " || sData == null) {
        elCell.innerHTML = "";
    } else {
        elCell.innerHTML = sData;
    }
}
//自定义查询
var fnCustomQueryRe = function (condition) {
    try {
        if (fkey != '00000000-0000-0000-0000-000000000000') {
            if (hrCaption == "year") {
                const_CustomCondition = condition + "and " + window.encodeURI("datepart(yy,starttime)=" + fkey);
            } else if (hrCaption == "term") {
                const_CustomCondition = condition + "and " + window.encodeURI(" termname='" + fkey + "'");
            } else if (hrCaption == "yearAll") {
                const_CustomCondition = condition;
            } else {
                const_CustomCondition = condition + "and " + window.encodeURI(" datepart(yy,starttime)=" + hrCaption + " and datepart(mm,starttime)=" + fkey);
            }
        }
        else
            const_CustomCondition = condition;
    } catch (e) {
        const_CustomCondition = condition;
    }

    RefreshData();
}
//格式化学员状态
var fnState = function (elCell, oRecord, oColumn, sData) {
    if (sData == "0") {
        elCell.innerHTML = "<font color='red'>学习中</font>";
    } else if (sData == "1") {
        elCell.innerHTML = "<font>合格毕业</font>";
    } else if (sData == "2") {
        elCell.innerHTML = "<font>优秀毕业</font>";
    } else if (sData == "3") {
        elCell.innerHTML = "<font>不合格未毕业</font>";
    } else if (sData == "4") {
        elCell.innerHTML = "<font>转期</font>";
    }
     else {
        elCell.innerHTML = sData;
    }
}
//结业操作
var fnEdits = function () {
    var tempIDS = "", tempNum = 0;
    var list = this.mDataTable.getRecordSet()._records;

    if (list == null || list.length == 0) {
        alert("请选择一条记录");
        return;
    }
    for (var i = 0; i < list.length; i++) {
        if (list[i]._oData["iSun_Selected"] == true) {
            tempNum = 1;
            tempIDS = tempIDS + list[i].getData("ID") + ",";
        }
    }
    if (tempNum == 0) {
        alert("请勾中一条或多条记录");
        return;
    }
    tempIDS = tempIDS.substr(0, tempIDS.length - 1);
    var SetManagerURL = "../../Crm/Deliver/AddHrStudentInfo.aspx?r=";
    var pagetitle = "学员结业操作";
    document.getElementById("EditUIWindow").src = SetManagerURL + Math.random() + "&id=" + tempIDS + "&title=" + encodeURI(pagetitle);
    YAHOO.example.container.dialog1.show();
    document.getElementById("yui-gen31-button").style.display = "block";

//    var recordID = myDataTable.getSelectedRows()[0];
//    record = myDataTable.getRecord(recordID);
//    if (record == null) {
//        alert("请选择一条记录");
//        return;
//    }
//    var vState = record.getData("StudentState"); 
//    if (vState == "" || vState == "0" || vState=="学习中") {
//        var SetManagerURL = "../../Crm/Deliver/AddHrStudentInfo.aspx?r=";
//        var vid = record.getData(const_entityID);
//        if (vid != undefined && vid != "") {
//            var pagetitle = "学员结业操作";
//            document.getElementById("EditUIWindow").src = SetManagerURL + Math.random() + "&id=" + vid + "&explain=" + encodeURI(record.getData("Review")) + "&title=" + encodeURI(pagetitle) + "";
//            YAHOO.example.container.dialog1.show();
//            document.getElementById("yui-gen31-button").style.display = "block";
//        }
//    } else {
//        alert("选中的学员有已结业");
//        return;
//    }
}
//分班操作
var fnAddOrder = function () {
    var tempIDS = "", tempNum=0;
    var list = this.mDataTable.getRecordSet()._records;

    if (list == null || list.length == 0) {
        alert("请选择一条记录");
        return;
    }
    for (var i = 0; i < list.length; i++) {
        if (list[i]._oData["iSun_Selected"] == true) {
            tempNum = 1;
            tempIDS = tempIDS + list[i].getData("ID") + ",";
        }
    }
    if (tempNum == 0) {
        alert("请勾中一条或多条记录");
        return;
    }
    tempIDS = tempIDS.substr(0, tempIDS.length - 1);
    var SetManagerURL = "../../Crm/Deliver/AddHrStudentInfo.aspx?r=";
    var pagetitle = "学员分团操作";
    document.getElementById("EditUIWindow").src = SetManagerURL + Math.random() + "&strClassId=" + tempIDS + "&title=" + encodeURI(pagetitle);
    YAHOO.example.container.dialog1.show();
    document.getElementById("yui-gen31-button").style.display = "block";

} 

 //跳转分班操作
var fnPartClass = function () {
    if (hrCaption == "term") {
        window.parent.$("#tabs").tabs('close', '学员分班');
        var pagetitle = "学员分班";
        parent.addTabs(pagetitle, '../Crm/StudentHrSign.aspx?r=' + Math.random() + '&key=' + encodeURI(fkey) + '&title=' + encodeURI(pagetitle));
        parent.NeedRefreshPage = this;
    } else { alert("请从左边树选择期数."); return; }

}

